
#ifndef GRAPHICS_H
#define GRAPHICS_H

#include <iostream>
#include "Vec3f.h"
#include "GraphicsWindow.h"
#include "Sim.h"
#include "GravBody.h"
#include "Geosphere.h"
#include "GeosphereFace.h"
#include "GeosphereVert.h"
#include "Star.h"
#include "Camera.h"
#include "TerrainTexture.h"
#include "Picker.h"
#include "Targeter.h"
#include "OSD.h"

//use a define for moonViewHeight because I'm lazy...
#define MOON_VIEW_H		150

using namespace std;

class Graphics : public GraphicsWindow {

	public:

		Graphics(int width, int height, Sim* pSim);

		// Defining GraphicsWindowPrimer's virtual funcitons
		void displayFunc();
		void idleFunc();
		void keyboardFunc(unsigned char key, int x, int y);
		void motionFunc(int x, int y);
		void mouseFunc(int button, int state, int x, int y);
		void passiveMotionFunc(int x, int y);
		void reshapeFunc(int w, int h);   
		void specialFunc(int key, int x, int y);

	private:

		void initialize();
		void draw();
		void drawViewScreen();
		void drawStars();
		void drawGravBodies();
		void drawNebula();
		void initNebula();
		void createGeosphereDisplayLists();
		void drawGeosphere(float rad, int detailLevels);
		void drawPickingSpheres();
		void drawGeosphereFace(GeosphereFace* face, int levelsLeft);
		void drawGeosphereHistory(GravBody* gravBody, const Vec3f* loc);
		void drawGeosphereDebrisHistory( GravBody* gravBody, const Vec3f* loc ); 
		void toggleTargeting();

		Sim* sim;
		Camera cam;
		Camera viewCam;
		int screenWidth, screenHeight;
		int followBodyIndex;
		bool keyRightDown;
		bool keyLeftDown;
		bool camAtMoon;
		bool cameraMoveMode;		
		float lightPos[4];
		float lineupWidth; 
		Star* stars;
		unsigned int numStars;
		int dlStars;
		int dlGeo;
		Picker pk;
		Picker viewPk;		
		OSD osd;

		//targeting stuff
		Targeter targSphere;
		Vec3f targetPos;
		bool targeting;
		int missilesFired;

		//the texture for the nebula
		GLuint nebulaT;
		GLUquadric* nebulaSphere;
		GLUquadric* q1;

		Vec3f eye;
		Vec3f view;

		float ones[4];
		float mids[4];
		float zeros[4];
		float alphas[4];
		float blues[4];
		float reds[4];

		TerrainTexture tt;
		unsigned int moonTexture;

		//defines the height of the moon view window thing
		int moonViewHeight;

		//to store stuff
		float proj_mat[16];
		int   viewport[4];
		float modl_mat[16];
		float oldZoom;

};

#endif
